<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="我的机构">
<style>
    /***循环的表单设置***/
    .bui-select .bui-select-input {
        width: 250px;
    }
</style>
<div class="xm-offline">
    <div class="row">
        <div class="panel">
            <div class="panel-body">
                <form id="detailsForm" class="form-horizontal">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构名称：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="name"
                                   id="name" disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            负责人：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principal"
                                   id="principal" disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span10" name="principalPhone"
                                   id="principalPhone" disabled="disabled"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构编码：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="id"
                                   id="code" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            成立时间：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="buildTime"
                                   id="buildTime" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            入驻日期：
                        </label>

                        <div class="controls">
                            <input type="text" class="tel control-text span-width span8" name="createTime"
                                   id="createTime" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            所在地区：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span2" name="province"
                                   disabled="disabled" id="province"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="city"
                                   disabled="disabled" id="city"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span2" name="area"
                                   disabled="disabled" id="area"/>&nbsp;&nbsp;
                            <input type="text" class="control-text span-width span10" name="address"
                                   disabled="disabled" id="address"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            意向服务领域：
                        </label>

                        <div class="controls">
                            <input type="text" class="tel control-text span-width span8" name="field"
                                   id="field" disabled="disabled">
                        </div>
                    </div>
                    <div class="control-group" id="organization-img">
                        <label class="control-label">
                            <s>*</s>
                            机构图片：
                        </label>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构介绍：
                        </label>

                        <div class="controls control-row12" style="height: 350px;initialFrameWidth: 100%;"
                             id="organization-content">

                        </div>
                    </div>
                    <div class="control-group" id="organization-qrCode">
                        <label class="control-label">
                            <s>*</s>
                            机构二维码：
                        </label>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            机构级别：</label>

                        <div class="controls">
                            <input type="text" class="control-text" name="rank"
                                   disabled="disabled" id="rank"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            上级机构：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width " id="parentID" disabled>
                        </div>
                    </div>
                    <h3 class="offset2">下级机构
                    </h3>
                    <hr/>
                    <input type="hidden" class="control-text span-width " name="subID" id="sub">

                    <div id="subGrid" class="sub-grid"></div>
                    <div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var str = JSON.stringify(data.data);
    sessionStorage.obj = str;
    var id = sessionStorage.id;
    $.ajax({
        type: "GET",
        url: "${basepath}/manage/organize/selectMyOrganize",
        dataType: "json",
        data: {
            id: id
        },
        success: function (data) {
            //声明各个变量
            var principal;
            var name;
            var principalPhone;
            var code;
            var buildTime;
            var createTime;
            var province;
            var city;
            var area;
            var address;
            var field;
            var inputList = data.data;
            //从data.data取值
            principal = inputList.principal;
            name = inputList.name;
            principalPhone = inputList.principalPhone;
            code = inputList.id;
            buildTime = inputList.buildTime;
            createTime = inputList.createTime;
            province = inputList.province;
            city = inputList.city;
            area = inputList.area;
            address = inputList.address;
            field = inputList.field;
            //从进行寻找对象塞值
            $("#principal").val(principal);
            $("#name").val(name);
            $("#principalPhone").val(principalPhone);
            $("#code").val(code);
            $("#buildTime").val(buildTime);
            $("#createTime").val(createTime);
            $("#province").val(province);
            $("#city").val(city);
            $("#area").val(area);
            $("#address").val(address);
            $("#field").val(field);
            //给机构图片取值塞值
            var imgArr = inputList.picture.split(",");
            var imgHtml = "";
            for (var i = 0; i < imgArr.length; i++) {
                imgHtml += '<img src="/' + imgArr[i] + '"/ style="height: 100px;width: 100px;margin:0 0 10px 10px" />';//创建img标签，图片地址赋值src
            }
            document.getElementById("organization-img").innerHTML += imgHtml;
            //给机构介绍塞值
            var textareaHtml = "";

            textareaHtml += '<textarea type="text" class="input-large" name="content" id="content">' + inputList.content + '</textarea>';
            //ueditor编辑器不可编辑状态
            $("#organization-content").html(textareaHtml);
            var editor = UE.getEditor('content', {
                readonly: true
            });

            //给机构二维码塞值
            var qrCodeHtml = "";
            qrCodeHtml += '<img src="/' + inputList.qrCode + '"/ style="height: 100px;width: 100px;margin:0 0 10px 10px" />';//创建img标签，图片地址赋值src
            document.getElementById("organization-qrCode").innerHTML += qrCodeHtml;
            //对机构级别的状态做判断塞值到input中
            var rank = inputList.rank;
            if (rank == "1") {
                $("#rank").val("A级");
            } else if (rank == "2") {
                $("#rank").val("B级");
            } else {
                $("#rank").val("C级");
            }

        }

    });


    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var subColumns = [
        {
            title: '机构名称', dataIndex: 'name', width: '50%'
        }
    ];
    var subStore = new Store({
        url: '${basepath}/manage/organize/selectSubList',
        autoLoad: true,
        params: {
            id: id
        },
        root: 'data'
    });
    var subGrid = new Grid.Grid({
        render: '#subGrid',
        width: '100%',//如果表格使用百分比，这个属性一定要设置
        columns: subColumns,
        idField: 'title',
        store: subStore
    });
    subGrid.render();


    $.ajax({
        type: "POST",
        dataType: "json",
        url: "${basepath}/manage/organize/selectSupList",
        data: {
            id: id
        },
        success: function (data) {
            $("#parentID").val(data.data[0].name);
        }
    });


</script>
</@page.pageBase>